package net.lab1024.sa.admin.util;

import lombok.extern.slf4j.Slf4j;
import net.lab1024.sa.admin.module.system.user.domain.RequestUser;
import net.lab1024.sa.admin.module.system.user.domain.RequestUsers;

/**
 * 请求用户  工具类
 *
 * @Author 1024创新实验室: 罗伊
 * @Date 2022-05-30 21:22:12
 
 
  * @Copyright  cpedu
 */
@Slf4j
public class UserRequestUtil {

    private static final ThreadLocal<RequestUsers> REQUEST_THREAD_LOCAL = new ThreadLocal<>();

    public static void setRequestUser(RequestUser requestUser) {
        REQUEST_THREAD_LOCAL.set(requestUser);
    }
    public static RequestUsers getRequestUser() {
        return REQUEST_THREAD_LOCAL.get();
    }

    public static String getRequestUserId() {
        RequestUsers requestUser = getRequestUser();
        return null == requestUser ? null : requestUser.getUserId();
    }


    public static void remove() {
        REQUEST_THREAD_LOCAL.remove();
    }


}
